package com.thprojects.myphotomemories.view.components;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ColorAdapter extends BaseAdapter{
	
	private Context mContext;
	private final int[] mColors = {	
		//pink
		Color.rgb(255, 147, 247),
		//fuchsia
		Color.rgb(255, 0, 212),
		//lilac
		Color.rgb(170, 0, 255),
		//purple
		Color.rgb(128, 0, 255),		
		//dark blue
		Color.rgb(0, 0, 159),
		//blue
		Color.rgb(0, 0, 255),
		//light blue
		Color.rgb(53, 157, 255),
		//cyan
		Color.rgb(0, 255, 255),
		//aquamarine
		Color.rgb(0, 255, 144),
		//dark green
		Color.rgb(0, 128, 47),
		//green
		Color.rgb(0, 255, 0),
		//lime
		Color.rgb(182, 255, 0),
		//yellow
		Color.rgb(255, 255, 0),
		//orange
		Color.rgb(255, 128, 0),
		//dark orange
		Color.rgb(255, 84, 28),
		//red
		Color.rgb(255, 0, 0),
		//brown
		Color.rgb(127, 55, 51),
		//white
		Color.rgb(255, 255, 255),
		//grey
		Color.rgb(128, 128, 128),
		//black
		Color.rgb(0, 0, 0)
	};

    public ColorAdapter(Context c) {
        mContext = c;
    }

	public int getCount() {
		return mColors.length;
	}

	public Object getItem(int arg0) {
		return mColors[arg0];
	}

	public long getItemId(int arg0) {
		return arg0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		 ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(30, 30));
            imageView.setBackgroundColor(mColors[position]);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }

        return imageView;
	}

}
